package com.rui.common.exception;

import com.rui.common.util.HttpStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常
 *
 * @author xr
 * @email xr@qq.com
 * @date 2020-01-01 00:00:00
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MyException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    private String message;
    private int code = 500;

    public MyException(String message) {
        super(message);
        this.message = message;
    }

    public MyException(String message, Throwable e) {
        super(message, e);
        this.message = message;
    }

    public MyException(String message, int code) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public MyException(String message, int code, Throwable e) {
        super(message, e);
        this.message = message;
        this.code = code;
    }

    public MyException(HttpStatus httpStatus) {
        super(httpStatus.getMsg());
        this.code = httpStatus.getCode();
        this.message = httpStatus.getMsg();
    }

}
